<fieldset>

    <legend>条件搜索</legend>

    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false"
        method="get" autocomplete="off">

        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">所属仓库</label>
            <div class="layui-input-inline">
                <select class='layui-select' name="ware_house_id" lay-search lay-filter="ware_house_id">
                    <!--{foreach $ware_house as $k=>$v}-->
                    <!--{eq name='v.id' value='$Think.get.ware_house_id|default=0'}-->
                    <option selected value='{$v.id}'>{$v.name}</option>
                    <!--{else}-->
                    <option value='{$v.id}'>{$v.name}</option>
                    <!--{/eq}-->
                    <!--{/foreach}-->
                </select>
            </div>
        </div>
        <div class="layui-form-item layui-inline">
            <label class="layui-form-label">运营计划</label>
            <div class="layui-input-inline">
                <select name="plan_id" lay-filter="detail_id" id="two_cate" lay-search></select>
            </div>
        </div>

        <div class="layui-form-item layui-inline">
            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
        </div>
    </form>

</fieldset>

<script>
    form.render()
    $(function () {
        $value = $('select[name="ware_house_id"]').val();
        plan_select($value);
    })
    //仓库运营计划二级联动
    form.on('select(ware_house_id)', function (data) {
        plan_select(data.value);
    });
    function plan_select(value) {
        var url = '{:url("home/plan_detail/getPlans")}?id=' + value;
        $.get(url, function (data) {
            $("#two_cate").empty();
            // $("#two_cate").append(new Option("请选择运营计划", ""));
            $.each(data.data, function (index, item) {
                if (item.id == '{$Think.get.plan_id|default=0}') {
                    $("#two_cate").append(new Option(item.plan_date, item.id, true, true));
                } else {
                    $("#two_cate").append(new Option(item.plan_date, item.id));
                }
            });
            layui.form.render("select");
        });
    }
</script>